<?php
namespace app\user\model;
use think\facade\Session;
use think\Model;
use think\facade\Cache;

class UserAuthRule extends Model
{
    // 获取导航栏
    public static function getNavbar()
    {
        //查询我的权限列表
        $user = User::where('id', UserId())->find();
        $access = implode(',', UserRule::where('id','in',$user['rule_id'])->column('rules'));
        $where = ['type' => 'nav', 'status' => 1];
        if($access){
            $where = "type='nav' and status = '1' and id in(".$access.")";
        }
        $navs = self::where($where)->order('sort_order asc')->select();
        return collection($navs)->toArray();
    }
}